<template>
    <el-form :model="eHourseForm" status-icon :rules="rules" ref="eHourseForm"
             label-width="150px"
             style="margin-top: 10px;color: #1f2d3d">
        <el-form-item class="form-label" label="发电厂房编号" prop="mid">
            <el-col :span="19">
                <el-input v-model="eHourseForm.mid" placeholder="发电厂房编号"
                          maxlength="11" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="发电厂房名称" prop="name">
            <el-col :span="19">
                <el-input v-model="eHourseForm.name" placeholder="发电厂房名称"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="发电厂房位置" prop="position">
            <el-col :span="19">
                <el-input v-model="eHourseForm.position" placeholder="发电厂房位置"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="经度" prop="longitude">
            <el-col :span="19">
                <el-input v-model="eHourseForm.longitude" placeholder="经度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="纬度" prop="latitude">
            <el-col :span="19">
                <el-input v-model="eHourseForm.latitude" placeholder="纬度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建设年代" prop="year">
            <el-col :span="19">
                <el-input v-model="eHourseForm.year" placeholder="建设年代"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="设防烈度" prop="intensity">
            <el-col :span="19">
                <el-input v-model="eHourseForm.intensity" placeholder="设防烈度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="装机容量" prop="installCapacity">
            <el-col :span="19">
                <el-input v-model="eHourseForm.installCapacity" placeholder="装机容量"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="发电类型" prop="generatingType">
            <el-col :span="19">
                <el-input v-model="eHourseForm.generatingType" placeholder="A.火力发电，B.水利发电"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="发电机总造价" prop="totalCostPowerPlant">
            <el-col :span="19">
                <el-input v-model="eHourseForm.totalCostPowerPlant" placeholder="发电机总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电设备造价" prop="costUbstationEquipment">
            <el-col :span="19">
                <el-input v-model="eHourseForm.costUbstationEquipment" placeholder="变电设备造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="发电设备总造价" prop="costGeneratingEquipment">
            <el-col :span="19">
                <el-input v-model="eHourseForm.costGeneratingEquipment" placeholder="发电设备总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="钢结构类建构物面积" prop="constructionAreaSteelStructures">
            <el-col :span="19">
                <el-input v-model="eHourseForm.constructionAreaSteelStructures" placeholder="钢结构类建构物面积"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="钢结构类建构物单价" prop="unitCostSteelStructure">
            <el-col :span="19">
                <el-input v-model="eHourseForm.unitCostSteelStructure" placeholder="钢结构类建构物单价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="钢筋混凝土类建构筑物面积" prop="areaReinforcedConcreteConstruction">
            <el-col :span="19">
                <el-input v-model="eHourseForm.areaReinforcedConcreteConstruction" placeholder="钢筋混凝土类建构筑物面积(m2)"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="钢筋混凝土类建构筑物单价" prop="unitCostReinforcedConcreteConstruction">
            <el-col :span="19">
                <el-input v-model="eHourseForm.unitCostReinforcedConcreteConstruction" placeholder="钢筋混凝土类建构筑物单价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="砖混结构类建构筑物面积" prop="constructionAreaMasonryStructureBuilding">
            <el-col :span="19">
                <el-input v-model="eHourseForm.constructionAreaMasonryStructureBuilding" placeholder="砖混结构类建构筑物面积(m2)"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="砖混结构类建构筑物单价" prop="unitCostMasonryStructureBuilding">
            <el-col :span="19">
                <el-input v-model="eHourseForm.unitCostMasonryStructureBuilding" placeholder="砖混结构类建构筑物单价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="备注" prop="remark">
            <el-col :span="19">
                <el-input v-model="eHourseForm.remark" placeholder="备注"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="关联子任务" prop="sid" style="display: none">
            <el-input v-model="eHourseForm.sid"
                      maxlength="20" autocomplete="off"/>
        </el-form-item>
    </el-form>
</template>

<script>
    import qs from 'qs';

    export default {
        name: "NewElectricityHourse",
        data() {
            return {
                eHourseForm: {
                    id: '',
                    mid: '',
                    name: '',
                    position: '',
                    lon: '',
                    lat: '',
                    year: '',
                    intensity: '',
                    installCapacity: '',
                    generatingType: '',
                    totalCostPowerPlant: '',
                    costUbstationEquipment: '',
                    costGeneratingEquipment: '',
                    constructionAreaSteelStructures: '',
                    unitCostSteelStructure: '',
                    areaReinforcedConcreteConstruction: '',
                    unitCostReinforcedConcreteConstruction: '',
                    constructionAreaMasonryStructureBuilding: '',
                    unitCostMasonryStructureBuilding: '',
                    remark: '',
                    sid: ''
                },
                rules: {
                    mid: [],
                    name: [],
                    position: [],
                    lon: [],
                    lat: [],
                    year: [],
                    intensity: [],
                    installCapacity: [],
                    generatingTYpe: [],
                    totalCostPowerPlant: [],
                    costUbstationEquipment: [],
                    costGeneratingEquipment: [],
                    constructionAreaSteelStructures: [],
                    unitCostSteelStructure: [],
                    areaReinforcedConcreteConstruction: [],
                    unitCostReinforcedConcreteConstruction: [],
                    constructionAreaMasonryStructureBuilding: [],
                    unitCostMasonryStructureBuilding: [],
                    remark: []
                }
            }
        },
        mounted() {
            if (this.id !== -1) {
                axios.post("/bjdzms/electricityMadeHourse/findById",
                    qs.stringify({
                        'id': this.id
                    })).then(res => {
                    this.eHourseForm = res.data.datas;
                });
            }
        },
        props: {
            sid: {
                type: Number,
                default: -1
            },
            id: {
                type: Number,
                default: -1
            }
        },
        methods: {
            to(path) {
                this.$router.push({name: path});
            },
            submitForm() {
                if (this.id !== -1) {
                    this.eHourseForm.id = this.id;
                    axios.post("/bjdzms/electricityMadeHourse/upd",
                        qs.stringify(this.eHourseForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                } else {
                    this.eHourseForm.sid = this.sid;
                    axios.post("/bjdzms/electricityMadeHourse/add",
                        qs.stringify(this.eHourseForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                }
            }
        }
    }
</script>

<style>
    .el-upload-dragger {
        height: 40px !important;
    }
</style>

<style scoped>
    .el-header {
        background: #EBEBEB;
        color: #e5e9ef;
        font-size: 2em;
        line-height: 80px;
        border: 5px solid #EBEBEB;
    }

    .el-main {
        background: #fff;
    }

    .el-container {
        height: 100%;
    }

    .el-form-item {
        width: 610px;
    }
</style>
